Fixes for blkif save/restore. A 'dd if=/dev/sda1 of=/dev/null'
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Wed, 28 Sep 2005 16:25:08 +0000 (17:25 +0100)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Wed, 28 Sep 2005 16:25:08 +0000 (17:25 +0100)
seems to lock up the domU kernel on restore still (can be
pinged but not ssh'ed). This still needs investigation.

Signed-off-by: Keir Fraser <keir@xensource.com>
linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c
linux-2.6-xen-sparse/drivers/xen/netback/common.h
linux-2.6-xen-sparse/drivers/xen/netback/netback.c

index 9d5b44d26cfb95ed05a1da40b5d0a27ca19f2c40..f919c09a8c9f503584dbd700e7b4ddaa478ab183 100644 (file)
@@ -57,11 +57,8 @@ static unsigned int blkif_state = BLKIF_STATE_DISCONNECTED;
 
 #define MAXIMUM_OUTSTANDING_BLOCK_REQS \
     (BLKIF_MAX_SEGMENTS_PER_REQUEST * BLKIF_RING_SIZE)
-#define GRANTREF_INVALID (1<<15)
 #define GRANT_INVALID_REF      (0xFFFF)
 
-static int recovery = 0; /* Recovery in progress: protected by blkif_io_lock */
-
 static void kick_pending_request_queues(struct blkfront_info *info);
 
 static void blkif_completion(struct blk_shadow *s);
@@ -84,18 +81,6 @@ static inline void ADD_ID_TO_FREELIST(
        info->shadow_free = id;
 }
 
-static inline void pickle_request(struct blk_shadow *s, blkif_request_t *r)
-{
-
-       s->req = *r;
-}
-
-static inline void unpickle_request(blkif_request_t *r, struct blk_shadow *s)
-{
-
-       *r = s->req;
-}
-
 static inline void flush_requests(struct blkfront_info *info)
 {
        RING_PUSH_REQUESTS(&info->ring);
@@ -235,7 +220,7 @@ static int blkif_queue_request(struct request *req)
                                rq_data_dir(req) );
 
                        info->shadow[id].frame[ring_req->nr_segments] =
-                               buffer_mfn;
+                               mfn_to_pfn(buffer_mfn);
 
                        ring_req->frame_and_sects[ring_req->nr_segments] =
                                blkif_fas_from_gref(ref, fsect, lsect);
@@ -247,7 +232,7 @@ static int blkif_queue_request(struct request *req)
        info->ring.req_prod_pvt++;
 
        /* Keep a private copy so we can reissue requests when recovering. */
-       pickle_request(&info->shadow[id], ring_req);
+       info->shadow[id].req = *ring_req;
 
        gnttab_free_grant_references(gref_head);
 
@@ -312,7 +297,7 @@ static irqreturn_t blkif_int(int irq, void *dev_id, struct pt_regs *ptregs)
 
        spin_lock_irqsave(&blkif_io_lock, flags);
 
-       if (unlikely(info->connected != BLKIF_STATE_CONNECTED || recovery)) {
+       if (unlikely(info->connected != BLKIF_STATE_CONNECTED)) {
                spin_unlock_irqrestore(&blkif_io_lock, flags);
                return IRQ_HANDLED;
        }
@@ -401,28 +386,24 @@ static void blkif_recover(struct blkfront_info *info)
                if (copy[i].request == 0)
                        continue;
 
-               /* Grab a request slot and unpickle shadow state into it. */
+               /* Grab a request slot and copy shadow state into it. */
                req = RING_GET_REQUEST(
                        &info->ring, info->ring.req_prod_pvt);
-               unpickle_request(req, &copy[i]);
+               *req = copy[i].req;
 
                /* We get a new request id, and must reset the shadow state. */
                req->id = GET_ID_FROM_FREELIST(info);
                memcpy(&info->shadow[req->id], &copy[i], sizeof(copy[i]));
 
                /* Rewrite any grant references invalidated by susp/resume. */
-               for (j = 0; j < req->nr_segments; j++) {
-                       if ( req->frame_and_sects[j] & GRANTREF_INVALID )
-                               gnttab_grant_foreign_access_ref(
-                                       blkif_gref_from_fas(
-                                               req->frame_and_sects[j]),
-                                       info->backend_id,
-                                       info->shadow[req->id].frame[j],
-                                       rq_data_dir(
-                                               (struct request *)
-                                               info->shadow[req->id].request));
-                       req->frame_and_sects[j] &= ~GRANTREF_INVALID;
-               }
+               for (j = 0; j < req->nr_segments; j++)
+                       gnttab_grant_foreign_access_ref(
+                               blkif_gref_from_fas(req->frame_and_sects[j]),
+                               info->backend_id,
+                               pfn_to_mfn(info->shadow[req->id].frame[j]),
+                               rq_data_dir(
+                                       (struct request *)
+                                       info->shadow[req->id].request));
                info->shadow[req->id].req = *req;
 
                info->ring.req_prod_pvt++;
@@ -430,15 +411,13 @@ static void blkif_recover(struct blkfront_info *info)
 
        kfree(copy);
 
-       recovery = 0;
-
        /* info->ring->req_prod will be set when we flush_requests().*/
        wmb();
 
        /* Kicks things back into life. */
        flush_requests(info);
 
-       /* Now safe to left other people use the interface. */
+       /* Now safe to let other people use the interface. */
        info->connected = BLKIF_STATE_CONNECTED;
 }
 
@@ -701,7 +680,6 @@ static int blkfront_suspend(struct xenbus_device *dev)
        kfree(info->backend);
        info->backend = NULL;
 
-       recovery = 1;
        blkif_free(info);
 
        return 0;
index 6311a7656b0cc64cbdf965b0e13ab8d6f1601813..1c907cff9cd3a3a8be7600f845fda27d4a29ebda 100644 (file)
@@ -22,8 +22,6 @@
 #include <asm-xen/gnttab.h>
 #include <asm-xen/driver_util.h>
 
-#define GRANT_INVALID_REF (0xFFFF)
-
 #if 0
 #define ASSERT(_p) \
     if ( !(_p) ) { printk("Assertion '%s' failed, line %d, file %s", #_p , \
index 4c218c262d78de9ede1ae50f186a61d98bde9488..3170303e8bb33975727ee78559f6e6fe9edd2b63 100644 (file)
@@ -434,7 +434,6 @@ inline static void net_tx_action_dealloc(void)
                gop->host_addr    = MMAP_VADDR(pending_idx);
                gop->dev_bus_addr = 0;
                gop->handle       = grant_tx_ref[pending_idx];
-               grant_tx_ref[pending_idx] = GRANT_INVALID_REF;
                gop++;
        }
        BUG_ON(HYPERVISOR_grant_table_op(